
import { Context, Controller, Inject } from "@midwayjs/core";
import { Get, Post, Body } from "@midwayjs/decorator";

import { Result } from "../../../types/comm.type";
import { MyLoginDTO , MyLoginVO } from "../../../types/my/user.my.type";
import { UserService } from "../../../service/user.service";


@Controller("/user")
export default class UserController {

    @Inject()
    userService: UserService;
    @Inject()
    ctx : Context

    @Post('/passport')
    async localPassport() {
      console.log('local user: ', this.ctx);
      return this.ctx;
    }

    @Post("/login")
    async login(@Body() loginDto: MyLoginDTO): Promise<Result<MyLoginVO>> {
        await this.userService.login(loginDto);
        return Result.ok({ token: "3234" });
    }

    @Get("/info")
    async info() {
        return Result.ok({ name: "张三" });
    }
}